package cn.wolfcode.trip.app.web.controller;

import cn.wolfcode.trip.base.service.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/strategies")
public class StrategyController {
    @Autowired
    private IStrategyService strategyService;
    @Autowired
    private IStrategyCatalogService catalogService;
    @Autowired
    private IStrategyDetailService detailService;

    @Autowired
    private ITravelService iTravelService;
    /*
        查询推荐的大攻略
        动作:GET
        资源:/strategies/commends
        参数:state=2
     */
    @GetMapping("/commends")
    public Object listCommend(Integer state) {
        return strategyService.listByState(state);
    }

    /*
        根据大攻略id查询攻略分类
        动作:GET
        资源:/strategies/{id}/catalogs
        参数:
     */
    @GetMapping("/{id}/catalogs")
    public Object listCatalog(@PathVariable Long id) {
        return catalogService.listCatalogByStrategyId(id);
    }

    /*
        根据id查询攻略文章
        动作:GET
        资源:/strategies/details/{id}
        参数:
     */
    @GetMapping("/details/{id}")
    public Object getStrategyDetail(@PathVariable Long id) {
        return detailService.get(id);
    }



}
